package com.csglxt.view.action;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.csglxt.base.BaseAction;
import com.csglxt.domain.Notice;

/**
 * 
 * @ClassName: HomeAction
 * @Description: 主页控制器
 * @author Delver_Si
 * @date 2015-5-28 下午11:58:45
 * 
 */

@Controller
@Scope("prototype")
@SuppressWarnings("serial")
public class HomeAction extends BaseAction<Notice> {
    @Resource
    SessionFactory sessionFactory;
    private List<Notice> noticeList;

    public List<Notice> getNoticeList() {
        return noticeList;
    }

    public void setNoticeList(List<Notice> noticeList) {
        this.noticeList = noticeList;
    }

    public String index() throws Exception {
        return "index";
    }

    public String top() throws Exception {
        return "top";
    }

    public String bottom() throws Exception {
        return "bottom";
    }

    public String left() throws Exception {
        return "left";
    }

    public String right() throws Exception {
        return "right";
    }

    @SuppressWarnings("unchecked")
    public String notice() throws Exception {
        noticeList = (List<Notice>) sessionFactory.getCurrentSession()
                .createQuery("From Notice order by date desc")
                .setFirstResult(0)// 开始从第几条开始取数据
                .setMaxResults(4).list();
        getValueStack().push(noticeList);
        return "notice";
    }
}
